﻿package com.coo.display 
{
	import com.coo.display.Baseshape;
	import flash.display.Graphics;
	import flash.geom.Point;
	
	/**
	 * ...
	 * @author iCoo
	 */
	public class Polygon extends Baseshape
	{
		private var _sideNum: int;
		private var _radius: int;
		
		public function Polygon( side: int = 3, radius: int = 100 ) 
		{
			_sideNum = side;
			_radius = radius;
			
			drawMain();
		}
		
		protected override function drawMain(): void
		{
			var g: Graphics = this.graphics;
			
			g.clear();
			g.lineStyle( lineThickness, lineColor, lineAlpha );
			g.beginFill( fillColor, fillAlpha );
			g.moveTo( _radius, 0 );
			
			var radians: Number = Math.PI * 2 / _sideNum;
			for (var i:int = 1; i <= _sideNum; i++) 
			{
				var p: Point = Point.polar( _radius, radians * i );
				g.lineTo( p.x, p.y );
			}
			
			g.endFill();
		}
	}
}